#include<bits/stdc++.h>
using namespace std;
signed main() {
//	system("start https://www.lanqiao.cn/problems/3492/learning/");

//	string ss = "5 6 8 6 9 1 6 1 2 4 9 1 9 8 2 3 6 4 7 7 5 9 5 0 3 8 7 5 8 1 5 8 6 1 8 3 0 3 7 9 2 7 0 5 8 8 5 7 0 9 9 1 9 4 4 6 8 6 3 3 8 5 1 6 3 4 6 7 0 7 8 2 7 6 8 9 5 6 5 6 1 4 0 1 0 0 9 4 8 0 9 1 2 8 5 0 2 5 3 3";
//
//	for(auto ii : ss){
//		if(ii != ' ')	cout << ii;
//		else cout << ',';
//	}

    vector<int> days = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

//    string s = "5686916124919823647759503875815861830379270588570991944686338516346707827689565614010094809128502533";

    vector<int> s = {5, 6, 8, 6, 9, 1, 6, 1, 2, 4, 9, 1, 9, 8, 2, 3, 6, 4, 7, 7, 5, 9, 5, 0, 3, 8, 7, 5, 8, 1, 5, 8, 6, 1, 8, 3, 0, 3, 7, 9, 2, 7, 0, 5, 8, 8, 5, 7, 0, 9, 9, 1, 9, 4, 4, 6, 8, 6, 3, 3, 8, 5, 1, 6, 3, 4, 6, 7, 0, 7, 8, 2, 7, 6, 8, 9, 5, 6, 5, 6, 1, 4, 0, 1, 0, 0, 9, 4, 8, 0, 9, 1, 2, 8, 5, 0, 2, 5, 3, 3};

    int ans = 0;
    set<int> computedCouple;

    for(int y1 = 0; y1 <= 82; y1++) {
        if(s[y1] != 2) continue;
        for(int y2 = y1 + 1; y2 <= 93; y2++) {
            if(s[y2] != 0) continue;
            for(int y3 = y2 + 1; y3 <= 94; y3++) {
                if(s[y3] != 2) continue;
                for(int y4 = y3 + 1; y4 <= 95; y4++) {
                    if(s[y4] != 3) continue;
                    for(int m1 = y4 + 1; m1 <= 96; m1++) {
                        if(s[m1] > 1) continue;
                        for(int m2 = m1 + 1 ; m2 <= 97; m2++) {
                        	if(!s[m1] && !s[m2]) continue;
                            if(s[m1] && s[m2] > 2) continue;
                            int month = s[m1] * 10 + s[m2];
                            for(int d1 = m2 + 1; d1 <= 98; d1++) {
                                if(s[d1] > 3) continue;
                                if(!s[m1] && s[m2] == 2 && s[d1] > 2) continue;
                                for(int d2 = d1 + 1; d2 <= 99; d2++) {
                                    int day = s[d1] * 10 + s[d2];
                                    if(day < 1 || day > days[month]) continue;

                                    int dateTime = 2023 * 10000 + month * 100 + day;
                                    if(!computedCouple.count(dateTime)) {
                                        ans++;
                                        computedCouple.insert(dateTime);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout << ans;
    return 0;
}

